package com.sky.controller.user;


import com.sky.dto.SetmealDTO;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.result.PageResult;
import com.sky.result.Result;
import com.sky.service.SetmealService;
import com.sky.vo.DishItemVO;
import com.sky.vo.SetmealVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("userSetmealController")
@Slf4j
@Api(tags = "套餐相关接口")
@RequestMapping("/user/setmeal")
public class SetmealController {

    @Autowired
    private SetmealService setmealService;


    //-4.1--根据分类id查询套餐   /user/setmeal/list
    @Cacheable(value = "setmealCache",key="'setmeal_'+#categoryId",unless = "#result.data.size()<1")
    @GetMapping("/list")
    @ApiOperation("根据分类id查询套餐 ")
    public Result selectByCategoryId(Long categoryId){
        List<Setmeal> setmeal=setmealService.selectByCategoryId(categoryId);
        return Result.success(setmeal);
    }


    //-4.1--根据套餐id查询菜品   /user/setmeal/dish/{id}
    @GetMapping("/dish/{id}")
    @ApiOperation("根据套餐id查询菜品 ")
    public Result selectDishItemVOBySetmealId(@PathVariable Long id){
        List<DishItemVO> dishItemVOS=setmealService.selectDishItemVOBySetmealId(id);
        return Result.success(dishItemVOS);
    }
}
